import { useDark, useToggle } from '@vueuse/core'
import { defineStore } from 'pinia'
const isDark = useDark()
// Create a new store instance.
const useSettings = defineStore('settings', {
  // other options...
  state: () => {
    return {
      type: 'default', // default | classic
      showSetting: false,
      isDark: isDark,
      animation: 'el-fade-in-linear',
      isOpen: true,
      language: 'zh-CN',
    }
  },
  actions: {
    showSettingPanel() {
      this.showSetting = true
    },
    hideSettingPanel() {
      this.showSetting = false
    },
    changeSkin() {
      const toggle = useToggle(isDark)
      toggle()
    },
    changeLanguage(language) {
      this.language = language
    },
  },
  getters: {},
  // 是否开启数据持久化
  persist: true,
})

export default useSettings
